import os
from flask_sqlalchemy import SQLAlchemy


class Config(object):
    DEBUG = False
    TESTING = False


class ProductionConfig(Config):
    TESTING = False
    # 生成密匙
    SECRET_KEY = os.urandom(24)
    DEBUG = True

    """
    创建flask mysql 连接配置文件；文件名称 config
    """
    DIALECT = 'mysql'
    DRIVER = 'mysqldb'
    USERNAME = 'root'
    PASSWORD = 'root'
    HOST = '127.0.0.1'
    PORT = '3306'
    DATABASE = 'vue_flask'
    SQLALCHEMY_DATABASE_URI ="{0}+{1}://{2}:{3}@{4}:{5}/{6}?charset=utf8".format(DIALECT,DRIVER,\
        USERNAME,PASSWORD,HOST,PORT,DATABASE)
    SQLALCHEMY_TRACK_MODIFICATIONS = False

    # # 配置数据库的地址
    # SQLALCHEMY_DATABASE_URI = 'mysql://root:root@127.0.0.1/vue_flask'
    # # 跟踪数据库的修改 不建议开启
    # SQLALCHEMY_TRACK_MODIFICATIONS = False

    # 七牛云
    QINIU_DOMAIN = 'http://cdn.fyy.cool/'
    
    APP = {
        'domain':'http:/127.0.0.1:5000'
    }
    # 微信小程序
    WX_APP = {
        'appid': 'wx15f20e174be245b4',
        'appkey': 'a2b1e3e809e40d0182c96f9e03824773',
        'paykey':'QixL2Q2d9LpyfomIDuFqqhFPJthkRRZz',
        'mch_id': '1230000109',
        'callback_url':'/api/order/callback'
    }
    API_IGNORE_URLS = [
        "^/api"
    ]
    
    PAY_STATUS_DISPLAY_MAPPING = {
        "0": "已关闭",
        "1": "已完成",
        "-8": "待支付",
        "-7": "待发货",
        "-6": "待确认",
        "-5": "待评价"
    }

    """分页配置"""
    PAGE_SIZE = 50
    PAGE_DISPLAY = 10


class DevelopmentConfig(Config):
    # 生成密匙
    SECRET_KEY = os.urandom(24)
    DEBUG = True

    """
    创建flask mysql 连接配置文件；文件名称 config
    """
    DIALECT = 'mysql'
    DRIVER = 'mysqldb'
    USERNAME = 'root'
    PASSWORD = 'root'
    HOST = '127.0.0.1'
    PORT = '3306'
    DATABASE = 'vue_flask'
    SQLALCHEMY_DATABASE_URI ="{0}+{1}://{2}:{3}@{4}:{5}/{6}?charset=utf8".format(DIALECT,DRIVER,\
        USERNAME,PASSWORD,HOST,PORT,DATABASE)
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    
    # # 配置数据库的地址
    # SQLALCHEMY_DATABASE_URI = 'mysql://PRIVATE@Link2046:root@127.0.0.1/vue_flask'
    # # 跟踪数据库的修改 不建议开启
    # SQLALCHEMY_TRACK_MODIFICATIONS = False
    # 七牛云
    QINIU_DOMAIN = 'http://cdn.fyy.cool/'

    APP = {
    'domain':'http:/127.0.0.1:5000'
    }

    # 微信小程序
    WX_APP = {
        'appid': 'wx15f20e174be245b4',
        'appkey': 'a2b1e3e809e40d0182c96f9e03824773'
    }
    API_IGNORE_URLS = [
        "^/api"
    ]

    PAY_STATUS_DISPLAY_MAPPING = {
        "0": "已关闭",
        "1": "已完成",
        "-8": "待支付",
        "-7": "待发货",
        "-6": "待确认",
        "-5": "待评价"
    }


class TestingConfig(Config):
    TESTING = True
